package com.luo.demo;

import java.util.ArrayList;

/**
 * @Author: luosiyu
 * @Description: 求质数合
 * @Version: 1.0
 */

public class PrimeSum {
    public static void main(String[] args) {
        int sum=0;
        ArrayList<Integer> ints = new ArrayList<>();
        s:
        for (int i = 2; i <= 50; i++) {
            for (int j=2;j<i;j++){
                if(i%j==0){//都没有整除则add。出现整除跳出循环回到外循环
                    continue s;
                }
            }
            ints.add(i);
//            sum+=i;
        }
        for (Integer anInt : ints) {
            sum+=anInt;
        }
        System.out.print(ints);
        System.out.println("="+sum);

    }
}
